import LayerManager from "./LayerManager"
import LayerInterface from "./LayerInterface"
import { logInfo } from "../tools/Define";
export default class StackLayerManager extends LayerManager {

    //添加layer
    pushView(view: LayerInterface) {
        this.list.push(view);
        // let node: Laya.View = layerInfo.getLayer()
        // node.zOrder = this.info.zOrder;
        view.setOrder(this.zOrder)
        this.root.addChild(view.getNode())
    }

    // 移除layer
    popView(view: LayerInterface): boolean {
        // logInfo(' this.list.length  ', this.list.length)
        if (!view) {
            if (this.list.length > 0) {
                let layerInfo = this.list.pop();
                layerInfo.exit();
                // 
                return true;
            } else {
                return false;
            }
        } else {
            return this.removeView(view);
        }
    }

    popAll() {
        let depth = this.list.length;
        for (let i = 0; i < depth; i++) {
            let layerInfo = this.list.pop();
            layerInfo.exit();
        }
    }
}
